using MicroMsg.Common.Utils;
using MicroMsg.Network;
using MicroMsg.Scene;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using Microsoft.Phone.Controls;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Resources;
namespace MicroMsg.UI.Page
{
	public class TestPage : BasePage
	{
		private const string sStrDefaultMsg = "this is test message";
		private const int cNDefaultTxtCnt = 10;
		private const string TAG = "TestPage";
		public static string sStrUserToSend = null;
		private static string sStrToSend = null;
		private static int sNTxtSendCnt = -1;
		private static int sNVoiceSendCnt = -1;
		private static int sNPicSendCnt = -1;
		private bool bIsFirstIn = true;
		internal Grid LayoutRoot;
		internal panelTitleControl panel1Line;
		internal Button btnReset;
		internal Button btnChangeNetwork991;
		internal Button btnChangeNetwork992;
		internal Grid ContentPanel;
		internal PhoneTextBox txtInUserToSend;
		internal StackPanel panelTextMsg;
		internal PhoneTextBox txtInTextToSend;
		internal PhoneTextBox txtInTextCnt;
		internal Button btnSendTxt;
		internal StackPanel panelVoiceMsg;
		internal PhoneTextBox txtInVoiceCnt;
		internal Button btnSendVoice;
		internal StackPanel panelPicMsg;
		internal PhoneTextBox txtInPicCnt;
		internal Button btnSendPic;
		private bool _contentLoaded;
		public TestPage()
		{
			this.InitializeComponent();
			base.add_Loaded(new RoutedEventHandler(this.TestPage_Loaded));
		}
		private void TestPage_Loaded(object sender, RoutedEventArgs e)
		{
			if (this.bIsFirstIn)
			{
				this.initUI();
			}
		}
		private void initUI()
		{
			if (!ToolFunction.isEmptyString(TestPage.sStrUserToSend))
			{
				this.txtInUserToSend.set_Text(TestPage.sStrUserToSend);
			}
			if (!ToolFunction.isEmptyString(TestPage.sStrToSend))
			{
				this.txtInTextToSend.set_Text(TestPage.sStrToSend);
			}
			if (TestPage.sNTxtSendCnt > 0)
			{
				this.txtInTextCnt.set_Text(string.Concat(TestPage.sNTxtSendCnt));
			}
			if (TestPage.sNVoiceSendCnt > 0)
			{
				this.txtInVoiceCnt.set_Text(string.Concat(TestPage.sNVoiceSendCnt));
			}
			if (TestPage.sNPicSendCnt > 0)
			{
				this.txtInPicCnt.set_Text(string.Concat(TestPage.sNPicSendCnt));
			}
		}
		private void btnChangeNetwork991_Click(object sender, RoutedEventArgs e)
		{
			HostService.setDebugHost("180.153.74.12", "180.153.74.10");
			HostService.setDebugMode(true);
		}
		private void btnChangeNetwork992_Click(object sender, RoutedEventArgs e)
		{
			HostService.setDebugHost("180.153.74.13", "180.153.74.11");
			HostService.setDebugMode(true);
		}
		private void btnReset_Click(object sender, RoutedEventArgs e)
		{
			TestPage.sStrUserToSend = "";
			TestPage.sStrToSend = "";
			TestPage.sNTxtSendCnt = -1;
			TestPage.sNVoiceSendCnt = -1;
			this.txtInTextCnt.set_Text("");
			this.txtInVoiceCnt.set_Text("");
			this.txtInPicCnt.set_Text("");
			this.txtInTextToSend.set_Text("");
			this.txtInUserToSend.set_Text("");
		}
		private void txtInUserToSend_GotFocus(object sender, RoutedEventArgs e)
		{
		}
		private void txtInUserToSend_TextChanged(object sender, TextChangedEventArgs e)
		{
		}
		private void txtInTextToSend_GotFocus(object sender, RoutedEventArgs e)
		{
		}
		private void txtInTextToSend_TextChanged(object sender, TextChangedEventArgs e)
		{
		}
		private void txtInTextCnt_GotFocus(object sender, RoutedEventArgs e)
		{
		}
		private void txtInTextCnt_TextChanged(object sender, TextChangedEventArgs e)
		{
		}
		private void btnSendTxt_Click(object sender, RoutedEventArgs e)
		{
			string strToSend = "this is test message";
			string text = this.txtInUserToSend.get_Text();
			if (ToolFunction.isEmptyString(text))
			{
				MessageBoxManager.ShowToast("用户名不能为空。", 2500, null, false);
				this.txtInUserToSend.Focus();
				return;
			}
			int nRepeatCnt = 10;
			if (!ToolFunction.isEmptyString(this.txtInTextToSend.get_Text()))
			{
				strToSend = this.txtInTextToSend.get_Text();
				TestPage.sStrToSend = strToSend;
			}
			if (!ToolFunction.isEmptyString(this.txtInTextCnt.get_Text()) && ToolFunction.checkIsNumber(this.txtInTextCnt.get_Text()))
			{
				nRepeatCnt = int.Parse(this.txtInTextCnt.get_Text());
				TestPage.sNTxtSendCnt = nRepeatCnt;
			}
			TestPage.sStrUserToSend = text;
			ServiceCenter.sceneSendMsg.testSendMsg(text, strToSend, nRepeatCnt);
		}
		private void txtInVoiceCnt_GotFocus(object sender, RoutedEventArgs e)
		{
		}
		private void txtInVoiceCnt_TextChanged(object sender, TextChangedEventArgs e)
		{
		}
		private void btnSendVoice_Click(object sender, RoutedEventArgs e)
		{
			string text = this.txtInUserToSend.get_Text();
			if (ToolFunction.isEmptyString(text))
			{
				MessageBoxManager.ShowToast("用户名不能为空。", 2500, null, false);
				this.txtInUserToSend.Focus();
				return;
			}
			int num = 10;
			if (ToolFunction.checkIsNumber(this.txtInVoiceCnt.get_Text()))
			{
				num = int.Parse(this.txtInVoiceCnt.get_Text());
				TestPage.sNVoiceSendCnt = num;
			}
			TestPage.sStrUserToSend = text;
			for (int i = 0; i < num; i++)
			{
				ServiceCenter.sceneUploadVoice.doSceneDirectWithoutRecord(text, 5 + i % 50);
			}
		}
		private void btnSendPic_Click(object sender, RoutedEventArgs e)
		{
			string text = this.txtInUserToSend.get_Text();
			if (ToolFunction.isEmptyString(text))
			{
				MessageBoxManager.ShowToast("用户名不能为空。", 2500, null, false);
				this.txtInUserToSend.Focus();
				return;
			}
			int num = 10;
			if (ToolFunction.checkIsNumber(this.txtInPicCnt.get_Text()))
			{
				num = int.Parse(this.txtInPicCnt.get_Text());
				TestPage.sNPicSendCnt = num;
			}
			TestPage.sStrUserToSend = text;
			Log.smethod_5("TestPage", "send img count = " + num);
			Uri uri = new Uri("Resource/Img/CommonUse/SexIco_man.png", 2);
			StreamResourceInfo resourceStream = Application.GetResourceStream(uri);
			Uri uri2 = new Uri("Resource/Img/CommonUse/DefaultHead.png", 2);
			StreamResourceInfo resourceStream2 = Application.GetResourceStream(uri2);
			Uri uri3 = new Uri("Resource/Img/CommonUse/SexIco_woman.png", 2);
			StreamResourceInfo resourceStream3 = Application.GetResourceStream(uri3);
			List<Stream> list = new List<Stream>();
			list.Add(resourceStream.get_Stream());
			list.Add(resourceStream2.get_Stream());
			list.Add(resourceStream3.get_Stream());
			List<Stream> list2 = list;
			for (int i = 0; i < num; i++)
			{
				ServiceCenter.sceneSendImg.doScene(text, "test image" + i, list2.get_Item(i % 3), 3, null);
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/LogView/TestPage.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.panel1Line = (panelTitleControl)base.FindName("panel1Line");
			this.btnReset = (Button)base.FindName("btnReset");
			this.btnChangeNetwork991 = (Button)base.FindName("btnChangeNetwork991");
			this.btnChangeNetwork992 = (Button)base.FindName("btnChangeNetwork992");
			this.ContentPanel = (Grid)base.FindName("ContentPanel");
			this.txtInUserToSend = (PhoneTextBox)base.FindName("txtInUserToSend");
			this.panelTextMsg = (StackPanel)base.FindName("panelTextMsg");
			this.txtInTextToSend = (PhoneTextBox)base.FindName("txtInTextToSend");
			this.txtInTextCnt = (PhoneTextBox)base.FindName("txtInTextCnt");
			this.btnSendTxt = (Button)base.FindName("btnSendTxt");
			this.panelVoiceMsg = (StackPanel)base.FindName("panelVoiceMsg");
			this.txtInVoiceCnt = (PhoneTextBox)base.FindName("txtInVoiceCnt");
			this.btnSendVoice = (Button)base.FindName("btnSendVoice");
			this.panelPicMsg = (StackPanel)base.FindName("panelPicMsg");
			this.txtInPicCnt = (PhoneTextBox)base.FindName("txtInPicCnt");
			this.btnSendPic = (Button)base.FindName("btnSendPic");
		}
	}
}
